package com.restaurant.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.basic.BasicOptionPaneUI.ButtonActionListener;

import com.restaurant.service.DetailService;
import com.restaurant.service.UserDao;
import com.restaurant.service.UserService;
import com.restaurant.service.impl.DetailServiceImpl;
import com.restaurant.service.impl.UserServiceImpl;
import com.restaurant.util.LoginConfig;
import com.restaurant.util.Result;
import com.restaurant.bean.User;

import TrzCreateBorder.TrzBorder;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JSplitPane;
import javax.swing.JDesktopPane;
import java.awt.Color;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JMenu;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.Component;
import java.awt.SystemColor;
import java.awt.CardLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.GroupLayout;
import javax.swing.Icon;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import java.awt.Dimension;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SpinnerNumberModel;

import java.awt.Font;
import javax.swing.UIManager;
import javax.swing.JSpinner;
import javax.swing.JToolBar;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import javax.swing.JProgressBar;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.BoxLayout;
/**
 * 主界面
 * @author TRz
 * @date 2020年8月4日下午1:47:41
 * @remarks TODO
 */
public class MainFrame extends JFrame {
	private UserDao userdao = new UserDao();
	private JPanel contentPane;
	private JButton buttonWaiMai;
	private JButton buttonDingDan;
	private JButton buttonVip;
	private JButton buttonPerson;
	private JButton buttonFriend;
	private JPanel card;
	private JPanel cardOrderMan;
	private JPanel cardFood;
	private JPanel cardVip;
	private JPanel cardPerson;
	private JPanel cardFriend;
	private JLabel vip;
	private JLabel person;
	private JLabel friend;
	private JButton toolbar_btShop;
	private JButton toolbar_btEntertainment;
	private JButton toolbar_btFruit;
	private JButton toolbar_btDrink;
	private JButton toolbar_btPill;
	private JButton toolbar_btCategory;
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel_2;
	private JLabel lblNewLabel_3;
	private JLabel lblNewLabel_4;
	private JLabel lblNewLabel_5;
	private JLabel lblNewLabel_6;
	private JLabel lblNewLabel; 
	private JButton toolbar_btFood;
	private JPanel panel_6;
	private JPanel panel_7;
	private JLabel lblNewLabel_7;
	private JLabel lblNewLabel_8;
	private JLabel lblNewLabel_9;
	private JLabel lblNewLabel_10;
	private JLabel lblNewLabel_11;
	private JLabel lblNewLabel_12;
	private JLabel lblNewLabel_13;
	private JLabel lblNewLabel_14;
	private JLabel lblNewLabel_15;
	private JLabel lblNewLabel_16;
	private JLabel lblNewLabel_17;
	private JLabel lblNewLabel_18;
	private JButton panelFood_btAccounts;
	private JLabel lblNewLabel_19;
	private JSpinner spHXY;
	private JSpinner spQCCR;
	private JSpinner spTY;
	private JSpinner spHG;
	private JSpinner spKY;
	private JSpinner spsteak;
	public double countAll = 0;
	private JLabel lblNewLabel_22;
	private JLabel lblNewLabel_21;
	private JButton btnNewButton;
	private JLabel lblNewLabel_22_1;
	private JLabel lblNewLabel_22_2;
	private JLabel lblNewLabel_22_3;
	private JLabel lblNewLabel_22_4;
	private JLabel lblNewLabel_22_5;
	private JLabel lblNewLabel_22_6;
	private JButton btnNewButton_1;
	private JButton btnNewButton_2;
	private JButton btnNewButton_3;
	private JButton btnNewButton_4;
	private JButton btnNewButton_5;
	private JButton btnNewButton_6;
	private DetailService serviceDeail = new DetailServiceImpl();
	private UserService serviceUser = new UserServiceImpl();
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainFrame() {
		setResizable(false);
		setTitle("GhostOrder");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 493, 621);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBackground(Color.WHITE);
		menuBar.setMargin(new Insets(1, 1, 1, 1));
		setJMenuBar(menuBar);
		
		buttonWaiMai = new JButton("外卖");
		buttonWaiMai.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout cardLayout = (CardLayout) card.getLayout();
				cardLayout.show(card, "name_600018118105600");
				
			}
		});

		buttonWaiMai.setFocusPainted(false);
		buttonWaiMai.setBackground(SystemColor.inactiveCaptionBorder);
		buttonWaiMai.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ic_kf.png")));
		menuBar.add(buttonWaiMai);
		
		buttonDingDan = new JButton("订单管理");
		buttonDingDan.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout cardLayout = (CardLayout) card.getLayout();
				cardLayout.show(card, "name_599972609283500");	
			}
		});
		buttonDingDan.setFocusPainted(false);
		buttonDingDan.setBackground(SystemColor.inactiveCaptionBorder);
		buttonDingDan.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ic_order1.png")));
	
		menuBar.add(buttonDingDan);
		
		buttonVip = new JButton("会员管理");
		buttonVip.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout cardLayout = (CardLayout) card.getLayout();
				cardLayout.show(card, "name_600023947268700");	
			}
		});
		buttonVip.setFocusPainted(false);
		buttonVip.setBackground(SystemColor.inactiveCaptionBorder);
		buttonVip.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ic_masonry.png")));
		menuBar.add(buttonVip);
		
		buttonPerson = new JButton("个人中心");
		buttonPerson.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout cardLayout = (CardLayout) card.getLayout();
				cardLayout.show(card, "name_600026916141200");	
			}
		});
		buttonPerson.setFocusPainted(false);
		buttonPerson.setBackground(SystemColor.inactiveCaptionBorder);
		buttonPerson.setIcon(new ImageIcon(MainFrame.class.getResource("/images/姓名 用户名 昵称.png")));
		menuBar.add(buttonPerson);
		
		buttonFriend = new JButton("朋友圈");
		buttonFriend.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout cardLayout = (CardLayout) card.getLayout();
				cardLayout.show(card, "name_600028906509900");	
			}
		});
		buttonFriend.setInheritsPopupMenu(true);
		buttonFriend.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ic_desktop.png")));
	
		buttonFriend.setFocusPainted(false);
		buttonFriend.setBackground(SystemColor.inactiveCaptionBorder);
		menuBar.add(buttonFriend);
		contentPane = new JPanel();
		contentPane.setForeground(SystemColor.inactiveCaptionBorder);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		card = new JPanel();
		card.setBounds(5, 5, 451, 550);
		contentPane.add(card);
		card.setLayout(new CardLayout(0, 0));
		
		cardFood = new JPanel();
		card.add(cardFood, "name_600018118105600");
		cardFood.setLayout(new BorderLayout(0, 0));
		
		JPanel toolbar = new JPanel();
		toolbar.setBackground(new Color(204, 204, 255));
		toolbar.setPreferredSize(new Dimension(10, 62));
		toolbar.setBorder(new MatteBorder(2, 2, 2, 2, (Color) new Color(255, 255, 255)));
		cardFood.add(toolbar, BorderLayout.NORTH);
		toolbar_btFood = new JButton("");
		toolbar_btFood.setIcon(new ImageIcon(MainFrame.class.getResource("/images/炸鸡 (1).png")));
		toolbar_btFood.setFocusPainted(false);
		toolbar_btFood.setContentAreaFilled(false);
		toolbar_btFood.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btShop = new JButton("");
		toolbar_btShop.setIcon(new ImageIcon(MainFrame.class.getResource("/images/商店.png")));
		toolbar_btShop.setFocusPainted(false);
		toolbar_btShop.setContentAreaFilled(false);
		toolbar_btShop.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btEntertainment = new JButton("");
		toolbar_btEntertainment.setIcon(new ImageIcon(MainFrame.class.getResource("/images/休闲.png")));
		toolbar_btEntertainment.setFocusPainted(false);
		toolbar_btEntertainment.setContentAreaFilled(false);
		toolbar_btEntertainment.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btFruit = new JButton("");
		toolbar_btFruit.setIcon(new ImageIcon(MainFrame.class.getResource("/images/水果.png")));
		toolbar_btFruit.setFocusPainted(false);
		toolbar_btFruit.setContentAreaFilled(false);
		toolbar_btFruit.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btDrink = new JButton("");
		toolbar_btDrink.setIcon(new ImageIcon(MainFrame.class.getResource("/images/饮料.png")));
		toolbar_btDrink.setFocusPainted(false);
		toolbar_btDrink.setContentAreaFilled(false);
		toolbar_btDrink.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btPill = new JButton("");
		toolbar_btPill.setIcon(new ImageIcon(MainFrame.class.getResource("/images/药箱.png")));
		toolbar_btPill.setFocusPainted(false);
		toolbar_btPill.setContentAreaFilled(false);
		toolbar_btPill.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		toolbar_btCategory = new JButton("");
		toolbar_btCategory.setIcon(new ImageIcon(MainFrame.class.getResource("/images/icon_行业分类.png")));
		toolbar_btCategory.setFocusPainted(false);
		toolbar_btCategory.setContentAreaFilled(false);
		toolbar_btCategory.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		panelFood_btAccounts = new JButton("");
		panelFood_btAccounts.setIcon(new ImageIcon(MainFrame.class.getResource("/images/确认.png")));
		panelFood_btAccounts.setFocusPainted(false);
		panelFood_btAccounts.setContentAreaFilled(false);
		panelFood_btAccounts.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		panelFood_btAccounts.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//创建一个result 返回余额是否大于购买商品得总价
				Result result1 = new Result();
				Result result2 = new Result();
				//集合用来存储每个商品的数量
				List<Integer> listCount = new ArrayList<Integer>();
				listCount.add((int) spHXY.getValue() );
				listCount.add((int) spQCCR.getValue() );
				listCount.add((int) spTY.getValue() );
				listCount.add((int) spHG.getValue() );
				listCount.add((int) spKY.getValue() );
				listCount.add((int) spsteak.getValue() );
				//遍历每个元素 
				for (int i = 0; i < listCount.size(); i++) {
					//更新数据库中用户订单的商品数量
					update(listCount.get(i), i);
					//计算所有商品的总价
					countAll += getCountAll(listCount.get(i),i);
				}
				result1 = serviceUser.getBalance(LoginConfig.reader().get(0), countAll);
				if (result1.getStatus() == 200) {
					//可以进入购买
					result2 = serviceUser.setUserBalance(LoginConfig.reader().get(0),countAll);
					//int j = userdao.buy(countAll);
					if (result2.getStatus() == 200) {
						//购买成功
						JOptionPane.showMessageDialog(null, result2.getMsg());
						new OrderFrame().setVisible(true);;
					}else {
						JOptionPane.showMessageDialog(null, result2.getMsg());
						System.out.println(00);
					}
					return;
				}else {
					JOptionPane.showMessageDialog(null, result1.getMsg());
					System.out.println(11);
				}
			}
		});

		//***************************************************
		/*toolbar_btFood = createButton("/images/炸鸡 (1).png");
		toolbar_btShop = createButton("/images/商店.png");
		toolbar_btEntertainment = createButton("/images/休闲.png");
		toolbar_btFruit = createButton("/images/水果.png");
		toolbar_btDrink = createButton("/images/饮料.png");
		toolbar_btPill = createButton("/images/药箱.png");
		toolbar_btCategory = createButton("/images/icon_行业分类.png");
		panelFood_btAccounts = createButton("/images/确认.png");*/
		//***************************************************
		
		lblNewLabel = new JLabel("美食");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_1 = new JLabel("商店");
		lblNewLabel_1.setForeground(Color.RED);
		lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_2 = new JLabel("休闲");
		lblNewLabel_2.setForeground(Color.RED);
		lblNewLabel_2.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_3 = new JLabel("水果");
		lblNewLabel_3.setForeground(Color.RED);
		lblNewLabel_3.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_4 = new JLabel("饮品");
		lblNewLabel_4.setForeground(Color.RED);
		lblNewLabel_4.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_5 = new JLabel("药品");
		lblNewLabel_5.setForeground(Color.RED);
		lblNewLabel_5.setFont(new Font("宋体", Font.PLAIN, 14));
		
		lblNewLabel_6 = new JLabel("全部分类");
		lblNewLabel_6.setForeground(Color.RED);
		lblNewLabel_6.setFont(new Font("宋体", Font.PLAIN, 14));
		
		GroupLayout gl_toolbar = new GroupLayout(toolbar);
		gl_toolbar.setHorizontalGroup(
			gl_toolbar.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_toolbar.createSequentialGroup()
					.addGap(36)
					.addGroup(gl_toolbar.createParallelGroup(Alignment.LEADING)
						.addComponent(toolbar_btFood, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblNewLabel, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
					.addGroup(gl_toolbar.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_toolbar.createSequentialGroup()
							.addGap(22)
							.addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addGap(22)
							.addComponent(lblNewLabel_2, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addGap(22)
							.addComponent(lblNewLabel_3, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addGap(22)
							.addComponent(lblNewLabel_4, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addGap(22)
							.addComponent(lblNewLabel_5, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addGap(21)
							.addComponent(lblNewLabel_6, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addGap(20)
							.addComponent(toolbar_btShop, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(20)
							.addComponent(toolbar_btEntertainment, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(20)
							.addComponent(toolbar_btFruit, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(20)
							.addComponent(toolbar_btDrink, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(20)
							.addComponent(toolbar_btPill, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(35)
							.addComponent(toolbar_btCategory, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(22, Short.MAX_VALUE))
		);
		gl_toolbar.setVerticalGroup(
			gl_toolbar.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_toolbar.createSequentialGroup()
					.addGap(5)
					.addGroup(gl_toolbar.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btFood, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btShop, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_1, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btFruit, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_3, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btDrink, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_4, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btPill, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_5, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btCategory, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_6, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_toolbar.createSequentialGroup()
							.addComponent(toolbar_btEntertainment, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
							.addGap(1)
							.addComponent(lblNewLabel_2, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		toolbar.setLayout(gl_toolbar);
		
		JPanel WaiMaiRoot = new JPanel();
		cardFood.add(WaiMaiRoot, BorderLayout.CENTER);
		WaiMaiRoot.setLayout(new CardLayout(0, 0));
		
		JPanel panelFood = new JPanel();
		panelFood.setBackground(UIManager.getColor("Menu.background"));
		WaiMaiRoot.add(panelFood, "name_623672414345900");
		
		lblNewLabel_7 = new JLabel("");
		lblNewLabel_7.setIcon(new ImageIcon(MainFrame.class.getResource("/images/鱼 (1).png")));
		
		lblNewLabel_8 = new JLabel("");
		lblNewLabel_8.setIcon(new ImageIcon(MainFrame.class.getResource("/images/芹菜.png")));
		
		lblNewLabel_9 = new JLabel("");
		lblNewLabel_9.setIcon(new ImageIcon(MainFrame.class.getResource("/images/鱼.png")));
		
		lblNewLabel_10 = new JLabel("");
		lblNewLabel_10.setIcon(new ImageIcon(MainFrame.class.getResource("/images/汤圆.png")));
		
		lblNewLabel_11 = new JLabel("");
		lblNewLabel_11.setIcon(new ImageIcon(MainFrame.class.getResource("/images/火锅.png")));
		
		lblNewLabel_12 = new JLabel("红烧鱼");
		lblNewLabel_12.setForeground(SystemColor.textHighlight);
		lblNewLabel_12.setFont(new Font("宋体", Font.BOLD, 18));
		
		lblNewLabel_13 = new JLabel("芹菜炒肉");
		lblNewLabel_13.setForeground(SystemColor.textHighlight);
		lblNewLabel_13.setFont(new Font("宋体", Font.BOLD, 18));
		
		lblNewLabel_14 = new JLabel("汤圆");
		lblNewLabel_14.setForeground(SystemColor.textHighlight);
		lblNewLabel_14.setFont(new Font("宋体", Font.BOLD, 18));
		
		lblNewLabel_15 = new JLabel("火锅");
		lblNewLabel_15.setForeground(SystemColor.textHighlight);
		lblNewLabel_15.setFont(new Font("宋体", Font.BOLD, 18));
		
		lblNewLabel_16 = new JLabel("烤鱼");
		lblNewLabel_16.setForeground(SystemColor.textHighlight);
		lblNewLabel_16.setFont(new Font("宋体", Font.BOLD, 18));
		
		lblNewLabel_17 = new JLabel("");
		lblNewLabel_17.setIcon(new ImageIcon(MainFrame.class.getResource("/images/肉.png")));
		
		lblNewLabel_18 = new JLabel("牛排");
		lblNewLabel_18.setForeground(SystemColor.textHighlight);
		lblNewLabel_18.setFont(new Font("宋体", Font.BOLD, 18));
	
		
		lblNewLabel_19 = new JLabel("结算");
		lblNewLabel_19.setForeground(new Color(0, 0, 255));
		lblNewLabel_19.setFont(new Font("宋体", Font.PLAIN, 14));
		
		spHXY = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		spQCCR = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		spTY = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		spHG = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		spKY = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		spsteak = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
		
		JLabel lblNewLabel_20 = new JLabel("样品图");
		lblNewLabel_20.setForeground(Color.RED);
		lblNewLabel_20.setFont(new Font("宋体", Font.PLAIN, 14));
		
		JLabel lblNewLabel_20_1 = new JLabel("菜名");
		lblNewLabel_20_1.setForeground(Color.RED);
		lblNewLabel_20_1.setFont(new Font("宋体", Font.PLAIN, 14));
		
		JLabel lblNewLabel_20_2 = new JLabel("数量");
		lblNewLabel_20_2.setForeground(Color.RED);
		lblNewLabel_20_2.setFont(new Font("宋体", Font.PLAIN, 14));
		
		JLabel lblNewLabel_20_3 = new JLabel("单价");
		lblNewLabel_20_3.setForeground(Color.RED);
		lblNewLabel_20_3.setFont(new Font("宋体", Font.PLAIN, 14));
		
		JLabel lblNewLabel_12_1 = new JLabel("30");
		lblNewLabel_12_1.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_1.setFont(new Font("宋体", Font.BOLD, 18));
		
		JLabel lblNewLabel_12_2 = new JLabel("15");
		lblNewLabel_12_2.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_2.setFont(new Font("宋体", Font.BOLD, 18));
		
		JLabel lblNewLabel_12_3 = new JLabel("10");
		lblNewLabel_12_3.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_3.setFont(new Font("宋体", Font.BOLD, 18));
		
		JLabel lblNewLabel_12_4 = new JLabel("20");
		lblNewLabel_12_4.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_4.setFont(new Font("宋体", Font.BOLD, 18));
		
		JLabel lblNewLabel_12_5 = new JLabel("40");
		lblNewLabel_12_5.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_5.setFont(new Font("宋体", Font.BOLD, 18));
		
		JLabel lblNewLabel_12_6 = new JLabel("60");
		lblNewLabel_12_6.setForeground(SystemColor.textHighlight);
		lblNewLabel_12_6.setFont(new Font("宋体", Font.BOLD, 18));
		
		JButton panelFood_btAccounts_1 = new JButton("");
		panelFood_btAccounts_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				userdao.recoverGE("红烧鱼");
//				userdao.recoverGE("牛排");
//				userdao.recoverGE("烤鱼");
//				userdao.recoverGE("汤圆");
//				userdao.recoverGE("芹菜炒肉");
//				userdao.recoverGE("火锅");
				
				Result result = new Result();
				result = serviceDeail.setDetailQuantity("红烧鱼");
				result = serviceDeail.setDetailQuantity("牛排");
				result = serviceDeail.setDetailQuantity("烤鱼");
				result = serviceDeail.setDetailQuantity("汤圆");
				result = serviceDeail.setDetailQuantity("芹菜炒肉");
				result = serviceDeail.setDetailQuantity("火锅");
			}
		});
		panelFood_btAccounts_1.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ic_order.png")));
		panelFood_btAccounts_1.setFocusPainted(false);
		panelFood_btAccounts_1.setContentAreaFilled(false);
		panelFood_btAccounts_1.setBorder(new LineBorder(Color.GRAY, 1, true));
		
		JLabel lblNewLabel_19_1 = new JLabel("复位");
		lblNewLabel_19_1.setForeground(Color.BLUE);
		lblNewLabel_19_1.setFont(new Font("宋体", Font.PLAIN, 14));
		GroupLayout gl_panelFood = new GroupLayout(panelFood);
		gl_panelFood.setHorizontalGroup(
			gl_panelFood.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panelFood.createSequentialGroup()
					.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(30)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_panelFood.createParallelGroup(Alignment.TRAILING)
									.addComponent(lblNewLabel_9)
									.addComponent(lblNewLabel_8)
									.addComponent(lblNewLabel_7)
									.addComponent(lblNewLabel_10)
									.addComponent(lblNewLabel_11))
								.addComponent(lblNewLabel_17))
							.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_panelFood.createSequentialGroup()
									.addGap(244)
									.addComponent(panelFood_btAccounts, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(lblNewLabel_19))
								.addGroup(gl_panelFood.createSequentialGroup()
									.addGap(45)
									.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_panelFood.createSequentialGroup()
											.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
												.addComponent(lblNewLabel_12)
												.addComponent(lblNewLabel_18, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
												.addComponent(lblNewLabel_14, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
												.addComponent(lblNewLabel_16, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
												.addComponent(lblNewLabel_13)
												.addComponent(lblNewLabel_20_1, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE))
											.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
												.addGroup(gl_panelFood.createSequentialGroup()
													.addGap(24)
													.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING, false)
														.addComponent(lblNewLabel_12_3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addComponent(lblNewLabel_12_2, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addComponent(lblNewLabel_12_5, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addComponent(lblNewLabel_12_1, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addComponent(lblNewLabel_12_4, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addComponent(lblNewLabel_12_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
														.addGroup(gl_panelFood.createSequentialGroup()
															.addComponent(panelFood_btAccounts_1, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
															.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
															.addComponent(lblNewLabel_19_1, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))))
												.addGroup(gl_panelFood.createSequentialGroup()
													.addGap(20)
													.addComponent(lblNewLabel_20_3, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE))))
										.addComponent(lblNewLabel_15, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE))
									.addGap(30)
									.addGroup(gl_panelFood.createParallelGroup(Alignment.TRAILING)
										.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
											.addComponent(spHXY, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
											.addComponent(spQCCR, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
											.addComponent(spTY, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
											.addComponent(spHG, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
											.addComponent(spKY, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
											.addComponent(spsteak, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE))
										.addComponent(lblNewLabel_20_2, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)))))
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(40)
							.addComponent(lblNewLabel_20)))
					.addContainerGap(54, Short.MAX_VALUE))
		);
		gl_panelFood.setVerticalGroup(
			gl_panelFood.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_panelFood.createSequentialGroup()
					.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panelFood.createSequentialGroup()
							.addContainerGap()
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_20)
								.addComponent(lblNewLabel_20_2, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
							.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_panelFood.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(lblNewLabel_7)
									.addGap(10)
									.addComponent(lblNewLabel_8)
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addComponent(lblNewLabel_10)
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addComponent(lblNewLabel_11)
									.addGap(10)
									.addComponent(lblNewLabel_9))
								.addGroup(gl_panelFood.createSequentialGroup()
									.addGap(18)
									.addComponent(lblNewLabel_12_1, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addGap(140)
									.addComponent(lblNewLabel_12_3, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addGap(125)
									.addComponent(lblNewLabel_12_5, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))))
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(11)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_20_1, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_20_3, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_12)
								.addComponent(spHXY, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(55)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_13, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
								.addComponent(spQCCR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_12_2, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
							.addGap(57)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_14, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
								.addComponent(spTY, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(56)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_15, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
								.addComponent(spHG, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblNewLabel_12_4, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
							.addGap(44)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNewLabel_16, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
								.addComponent(spKY, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGroup(gl_panelFood.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(10)
							.addComponent(lblNewLabel_17))
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(28)
							.addComponent(lblNewLabel_18, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_panelFood.createSequentialGroup()
							.addGap(28)
							.addGroup(gl_panelFood.createParallelGroup(Alignment.TRAILING)
								.addComponent(lblNewLabel_19)
								.addGroup(gl_panelFood.createSequentialGroup()
									.addGroup(gl_panelFood.createParallelGroup(Alignment.BASELINE)
										.addComponent(spsteak, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
										.addComponent(lblNewLabel_12_6, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addGroup(gl_panelFood.createParallelGroup(Alignment.TRAILING)
										.addComponent(panelFood_btAccounts, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
										.addComponent(panelFood_btAccounts_1, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
										.addComponent(lblNewLabel_19_1, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))))))
					.addGap(8))
		);
		panelFood.setLayout(gl_panelFood);
		
		JPanel panelShop = new JPanel();
		WaiMaiRoot.add(panelShop, "name_623675112950200");
		
		JPanel panel_3 = new JPanel();
		WaiMaiRoot.add(panel_3, "name_623680495427400");
		
		JPanel panel_4 = new JPanel();
		WaiMaiRoot.add(panel_4, "name_623682851504900");
		
		JPanel panel_5 = new JPanel();
		WaiMaiRoot.add(panel_5, "name_623684879455600");
		
		panel_6 = new JPanel();
		WaiMaiRoot.add(panel_6, "name_623713906400800");
		
		panel_7 = new JPanel();
		WaiMaiRoot.add(panel_7, "name_623717623563700");
		
		cardOrderMan = new JPanel();
		card.add(cardOrderMan, "name_599972609283500");
		cardOrderMan.setLayout(new BoxLayout(cardOrderMan, BoxLayout.X_AXIS));
		
		JScrollPane scrollPane = new JScrollPane();
		cardOrderMan.add(scrollPane);
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.WHITE);
		panel.setPreferredSize(new Dimension(120, 10));
		scrollPane.setRowHeaderView(panel);
		panel.setLayout(null);
		
		lblNewLabel_21 = new JLabel("订单日期");
		lblNewLabel_21.setFont(new Font("宋体", Font.PLAIN, 13));
		lblNewLabel_21.setBounds(0, 0, 54, 15);
		panel.add(lblNewLabel_21);
		
		lblNewLabel_22 = new JLabel("New label");
		lblNewLabel_22.setBorder(null);
		lblNewLabel_22.setBounds(0, 25, 120, 30);
		panel.add(lblNewLabel_22);
		
		btnNewButton = new JButton("显示订单");
		btnNewButton.setPreferredSize(new Dimension(80, 23));
		btnNewButton.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton.setBounds(0, 52, 120, 23);
		panel.add(btnNewButton);
		
		lblNewLabel_22_1 = new JLabel("New label");
		lblNewLabel_22_1.setBounds(0, 85, 120, 29);
		panel.add(lblNewLabel_22_1);
		
		lblNewLabel_22_2 = new JLabel("New label");
		lblNewLabel_22_2.setBounds(0, 144, 120, 35);
		panel.add(lblNewLabel_22_2);
		
		lblNewLabel_22_3 = new JLabel("New label");
		lblNewLabel_22_3.setBounds(0, 209, 120, 35);
		panel.add(lblNewLabel_22_3);
		
		lblNewLabel_22_4 = new JLabel("New label");
		lblNewLabel_22_4.setBounds(0, 275, 120, 35);
		panel.add(lblNewLabel_22_4);
		
		lblNewLabel_22_5 = new JLabel("New label");
		lblNewLabel_22_5.setBounds(0, 340, 120, 35);
		panel.add(lblNewLabel_22_5);
		
		lblNewLabel_22_6 = new JLabel("New label");
		lblNewLabel_22_6.setBounds(0, 405, 120, 35);
		panel.add(lblNewLabel_22_6);
		
		btnNewButton_1 = new JButton("显示订单");
		btnNewButton_1.setPreferredSize(new Dimension(80, 23));
		btnNewButton_1.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_1.setBounds(0, 111, 120, 23);
		panel.add(btnNewButton_1);
		
		btnNewButton_2 = new JButton("显示订单");
		btnNewButton_2.setPreferredSize(new Dimension(80, 23));
		btnNewButton_2.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_2.setBounds(0, 176, 120, 23);
		panel.add(btnNewButton_2);
		
		btnNewButton_3 = new JButton("显示订单");
		btnNewButton_3.setPreferredSize(new Dimension(80, 23));
		btnNewButton_3.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_3.setBounds(0, 242, 120, 23);
		panel.add(btnNewButton_3);
		
		btnNewButton_4 = new JButton("显示订单");
		btnNewButton_4.setPreferredSize(new Dimension(80, 23));
		btnNewButton_4.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_4.setBounds(0, 307, 120, 23);
		panel.add(btnNewButton_4);
		
		btnNewButton_5 = new JButton("显示订单");
		btnNewButton_5.setPreferredSize(new Dimension(80, 23));
		btnNewButton_5.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_5.setBounds(0, 372, 120, 23);
		panel.add(btnNewButton_5);
		
		btnNewButton_6 = new JButton("显示订单");
		btnNewButton_6.setPreferredSize(new Dimension(80, 23));
		btnNewButton_6.setBorder(new EmptyBorder(0, 0, 4, 0));
		btnNewButton_6.setBounds(0, 438, 120, 23);
		panel.add(btnNewButton_6);
		
		cardVip = new JPanel();
		card.add(cardVip, "name_600023947268700");
		
		vip = new JLabel("vip");
		cardVip.add(vip);
		
		cardPerson = new JPanel();
		card.add(cardPerson, "name_600026916141200");
		
		person = new JLabel("person");
		cardPerson.add(person);
		
		cardFriend = new JPanel();
		card.add(cardFriend, "name_600028906509900");
		
		friend = new JLabel("friend");
		cardFriend.add(friend);
		
		this.setLocationRelativeTo(null);
	}
	
	public JButton createButton(String iconPath) {
			// 加载资源文件
			URL url = getClass().getResource(iconPath);	
			Icon icon = new ImageIcon(url);
				
			// 设置图标
			JButton button = new JButton();
			button.setIcon(icon);
				
			// 其他设置
			button.setContentAreaFilled(false);  
			button.setFocusPainted(false); 

				
			// 设置默认border为灰色
			button.setBorder(BorderFactory.createLineBorder(Color.gray));
			TrzBorder.addPadding(button, 3);

			// 创建鼠标事件监听：鼠标移入时，更换border为蓝色
			button.addMouseListener(new MouseAdapter() {
						
				@Override
				public void mouseEntered(MouseEvent e)
				{
					button.setBorder(BorderFactory.createLineBorder(Color.blue));
					TrzBorder.addPadding(button, 4);
				}
					
				@Override
				public void mouseExited(MouseEvent e)
				{		
					button.setBorder(BorderFactory.createLineBorder(Color.gray));
					TrzBorder.addPadding(button, 4);
				}
			});
				
			return button;
	}
	public void update(int count,int i) {
		Result result = null;
		if (count != 0 && i == 0) {
			result  = serviceDeail.setDetailQuantity(count, "红烧鱼");
			//userdao.updateGE("红烧鱼",count);
		}else if(count != 0 && i == 1) {
			result  = serviceDeail.setDetailQuantity(count, "芹菜炒肉");
			//userdao.updateGE("芹菜炒肉",count);
		}else if(count != 0 && i == 2) {
			result  = serviceDeail.setDetailQuantity(count, "汤圆");
			//userdao.updateGE("汤圆",count);
		}else if(count != 0 && i == 3) {
			result  = serviceDeail.setDetailQuantity(count, "火锅");
			//userdao.updateGE("火锅",count);
		}else if(count != 0 && i == 4) {
			result  = serviceDeail.setDetailQuantity(count, "烤鱼");
			//userdao.updateGE("烤鱼",count);
		}else if(count != 0 && i == 5) {
			result  = serviceDeail.setDetailQuantity(count, "牛排");
			//userdao.updateGE("牛排",count);
		}
	}
	
	/**
	 * 返回总价格
	 * @return
	 */
	public double getCountAll(int count,int i) {
		double countTemp = 0;
		if (count != 0 && i == 0) {
			countTemp += count * 30;
			
		}else if(count != 0 && i == 1) {
			countTemp += count * 15;
			
		}else if(count != 0 && i == 2) {
			countTemp += count * 10;
			
		}else if(count != 0 && i == 3) {
			countTemp += count * 20;
			
		}else if(count != 0 && i == 4) {
			countTemp += count * 60;
			
		}else if(count != 0 && i == 5) {
			countTemp += count * 40;
			
		}
		return countTemp;
	}
	/**
	 * 重载
	 * @return
	 */
	public double getCountAll() {
		return countAll;
	}
}